var strfeedback = '<ul class="feedback"><li class="header"><span>下载文件反馈</span></li><li class="items"><a title="禁书" href="javascript:void(0);" onclick="feedback_click(this,0);">禁书</a></li><li class="items"><a title="色情" href="javascript:void(0);" onclick="feedback_click(this,1);">色情</a></li><li class="items"><a title="涉及政治" href="javascript:void(0);" onclick="feedback_click(this,2);">涉及政治</a></li><li class="items"><a title="内容残缺" href="javascript:void(0);" onclick="feedback_click(this,3);">内容残缺</a></li><li class="items"><a title="不可阅读" href="javascript:void(0);" onclick="feedback_click(this,4);">不可阅读</a></li><li class="items"><a title="质量不高" href="javascript:void(0);" onclick="feedback_click(this,5);">质量不高</a><a title="下载失败" href="javascript:void(0);" onclick="feedback_click(this,6);">下载失败</a></li></ul>';
strfeedback = '';
$(document).ready(function() {
    if ((typeof $.cookie("identify") == 'undefined') || (typeof $.cookie("kindle_email") == 'undefined')) {
        ajaxGenid_refresh(localid);
    } else {
        uid = $.cookie("identify");
        if (uid > 0) {
            uemail = $.cookie("uemail");
            kindle_email = $.cookie("kindle_email");
            if (typeof $.cookie("isVip") == 'undefined') {
                isVip = "0";
                popalert(_ts("cookieserroryouneedsigninagain"));
                $.cookie("isVip", "0", {
                    expires: 360,
                    path: '/'
                });
            } else {
                isVip = $.cookie("isVip");
            }
            showUserID(uid);
            if (uemail.length > 5) {
                $("#identifyid").val(uemail);
                $("#bind_submit").attr('disabled', 'disabled');
                $("#identifyid").attr('disabled', 'disabled');
            }
            if (isVip == "1") {
                $("#identify").attr("title", "VIP ID:" + uid);
                $("#identify").addClass("vip");
                $("#muser").attr("src", "/manager/images/userv.png");
                $("#muser").attr("title", "VIP");
                if (uemail.length == 0) {
                    setTimeout(popalert(_ts("pleasesetemailtoprotectvipaccount")), 1000);
                }
            }
            $("#customer_id").show();
            CheckUnReadCount();
        }
    }
    $("#gvBooks tr").dblclick(function() {
        changeCheck($(this));
        setTimeout(check_drop_tags(), 100);
    });
    $("#gvBooks .gv_child input[type='checkbox']").change(function() {
        check_drop_tags();
    });
    if (bw == 'Kindle') {
        $("a,p,span,label,td,body").css("font-size", "36px");
        $(".gv_child").css("display", "inline-table");
        $(".list-edit,.child_send,.btnZip,#linkDelete,.selectExtension,input").css("display", "none");
        $(".book_child input,.book_child div,.book_child .list-idkey,.book_child .list-addtime,.chkAll,.addtools").hide();
        $(".child_extension").css({
            "background-size": "20% 80%",
            "padding-right": "30px",
            "color": "#000000",
            "font-weight": "bold"
        });
        $(".listEbook .covershow").css({
            "width": "160px",
            "height": "160px"
        });
        $(".covershow img").css("height", "160px");
        $("#retrieve_customer_id input").css({
            "height": "80px",
            "font-size": "40px"
        });
        $("#retrieve_btn").css({
            "height": "50px",
            "font-size": "30px"
        });
        $("#chkpassword,#resetemail,#btnResetPassword,#p_password,#retrieve_password").show();
        $("#retrieve_id,#chkpassword,#resetemail,#btnResetPassword,#p_password,#retrieve_password,#retrieve_btn").css({
            "height": "80px",
            "font-size": "40px",
            "padding": "20px"
        });
        $("#chkpassword").css({
            "height": "40px",
            "font-size": "40px",
            "padding": "30px",
            "border": "solid 2px #333333"
        });
        $("#retrieve_id,#resetemail,#retrieve_password").css({
            "width": "800px",
            "border": "solid 2px #333333"
        });
        $("#top_div,.toolbartable,#frmTitle_a,#frmTitle_a_2,#tdframe").css({
            "height": "100px"
        });
        $("#customer_id #identify").css({
            "font-size": "60px"
        });
        $("#customer_id #identify").attr("href", "/app_books/user.aspx?div=1&KeepThis=true&TB_iframe=true&height=960&width=660");
        $("#customer_id ul").css({
            "width": "300px"
        });
        strfeedback = '';
    }
    if (uid == 0 && localid.length < 3) {
        $("#retrieve_customer_id").show();
        $("#amenu").hide();
        $("#retrieve_customer_id").show();
        $("#retrieve_id").show();
        $("#retrieve_btn").show();
        $("#centerContent,#leftmenu2").hide();
        $("#frmTitle_b").css("width", "1px");
    }
});
function showUserID(suid) {
    $("#identify").html(trimusername(suid));
    if (typeof $.cookie("identifyusername") != "undefined") {
        if ($.cookie("identifyusername") != '') {
            $("#identify").html(trimusername($.cookie("identifyusername")));
        }
    }
}
function trimusername(ustr) {
    return ustr;
    if (ustr.length > 6) {
        return (ustr.substring(0, 3) + "*" + ustr.substring(ustr.length - 3));
    } else {
        return ustr;
    }
}
function show_send2kindle_bar() {
    return;
}
function checkAll(evt) {
    $("#gvBooks tr").find("input[type='checkbox']").attr("checked", evt.checked);
    check_drop_tags();
}
function changeCheck(evt) {
    var curr_id = $(evt).attr("id");
    if (evt.find("input[type='checkbox']").attr("checked")) {
        evt.find("input[type='checkbox']").attr("checked", false);
    } else {
        evt.find("input[type='checkbox']").attr("checked", true);
    }
}
function ExtensionFilter(str) {
    if (str.length > 0) {
        $("#gvBooks .gv_child").each(function() {
            var gvObj = $(this);
            gvObj.show();
            gvObj.find("td[class='list_extension'] a").each(function() {
                if (this.innerHTML == str) {
                    $(this).parent().parent().find("input[type='checkbox']").attr("checked", 'checked');
                }
            });
        });
        setTimeout(check_drop_tags(), 100);
    }
}
var pageWidth, centerLeftWidth, centerRightWidth;
pageWidth = 0;
centerLeftWidth = 300;
centerRightWidth = 0;
leftshow = true;
function centerLeft_change(show) {
    if (show) {
        $("#centerLeft").fadeIn("fast");
        $("#frmTitle_b,#frmTitle_a").animate({
            'width': "300px"
        }, 120).show();
        leftshow = false;
        $.cookie("leftshow", "1", {
            expires: 360,
            path: '/'
        });
    } else {
        $("#centerLeft").fadeOut("fast");
        $("#frmTitle_b,#frmTitle_a").animate({
            'width': "1px"
        }, 120).hide();
        leftshow = true;
        $.cookie("leftshow", "0", {
            expires: 360,
            path: '/'
        });
    }
}
function topArrow() {
    centerLeft_change(leftshow);
}
$(document).ready(function() {
    if (typeof $.cookie("leftshow") == 'undefined') {
        leftshow = true;
    } else {
        leftshow = ($.cookie("leftshow") == "1");
    }
    if (leftshow && uid > 0) {
        centerLeft_change(leftshow);
    } else {
        leftshow = true;
    }
    $("td[class=list_extension]").click(function() {
        if ($(this).find("a.child_extension").attr("href")) {
            click_key($(this).find("a.child_extension").attr("target"));
            $(this).find("a.child_extension").removeAttr("href");
            $(this).find("a.child_extension").css({
                "color": "#333333",
                "background-image": "none"
            });
            if (isVip == "1") {
                $(this).find("a.child_extension").css({
                    "color": "#333333",
                    "background-image": "none",
                    "padding-right": "4px"
                });
            }
            return false;
        } else {}
    });
    $("a[class=child_extension_2]").click(function() {
        if ($(this).attr("href")) {
            click_key($(this).attr("target"));
            $(this).removeAttr("href");
            $(this).css({
                "color": "#333333",
                "background-image": "url(manager/images/arrow-down.png)",
                "padding-right": "14px"
            });
            return false;
        } else {}
    });
    $("td[class=list_reader]").each(function() {
        if (!IsPC()) {
            $(this).find("a").attr("href", $(this).find("a").attr("href") + "&ismobile=1");
        } else {
            $(this).find("a").attr("href", $(this).find("a").attr("href") + "&agent=" + navigator.userAgent.toLowerCase());
        }
    });
    if (!IsPC()) {
        $("#lreader").attr("href", $("#lreader").attr("href") + "?ismobile=1");
    } else {
        $("#lreader").attr("href", $("#lreader").attr("href") + '?agent=' + navigator.userAgent.toLowerCase());
    }
    $("div.bookTags span[title='Download']").each(function() {
        $(this).parent().parent().parent().parent().find("a.child_extension").css({
            "color": "#333333",
            "padding-right": "4px",
            "background-image": "none"
        });
        $(this).hide();
    });
    $("div.bookTags span[title='Favorite']").each(function() {
        $(this).parent().parent().find("div.divfavorite").addClass("fav");
        $(this).hide();
    });
    $(".hpfavorite").click(function() {
        favorite_click(this);
    });
    $(".list-filesize_k").each(function() {
        var intSize = 0;
        intSize = $(this).html().replace("K", "");
        var limitedSize = 1024 * 5;
        if (isVip == '1') {
            limitedSize = 1024 * 8
        }
        if (intSize > limitedSize) {
            $(this).parent().parent().parent().find("td.list_send").find("a.child_send").css({
                "color": "#333333"
            });
            $(this).parent().parent().parent().find("td.list_send").find("a.child_send").attr("title", _ts("filelargerthan") + limitedSize + "K," + _ts("downloaddirectly") + "!");
            $(this).css({
                "color": "#215dc6"
            });
        } else {
            $(this).parent().parent().parent().find("td.list_send").find("a.child_send").attr("title", _ts("sendemailisoutdownloaddirectly"));
        }
    });
    $("div.addtools .moretags ul li.dp_tag input[type='checkbox']").change(function() {
        var evt_checked = $(this).attr("checked");
        var evt_tag = $(this).attr('title');
        $(".book_child input[type='checkbox']:checked").each(function() {
            var find_tag = $(this).parent().parent().find(".bookTags span[title='" + evt_tag + "']");
            if (find_tag.length == 0) {
                if (evt_checked) {
                    $(this).parent().parent().find(".bookTags").append("<span title='" + evt_tag + "'>" + evt_tag + "</span>");
                }
            } else {
                if (evt_checked) {
                    find_tag.show();
                } else {
                    find_tag.hide();
                }
            }
        });
        if (evt_checked.toString() == $(this).attr("status").toString()) {
            $(this).parent().find(".setTag").hide();
        } else {
            $(this).parent().find(".setTag").show();
        }
    });
});
function check_drop_tags() {
    var checked_count = $(".book_child input[type='checkbox']:checked").length;
    if (checked_count > 0) {
        $("div.addtools .moretags").css("display", "inline-table");
        $("div.addtools #linkDelete").css("display", "inline-table");
    } else {
        $("div.addtools .moretags").css("display", "none");
        $("div.addtools #linkDelete").css("display", "none");
    }
    $("div.addtools .moretags ul li.dp_tag").each(function() {
        var this_tag_count = $(".book_child input[type='checkbox']:checked").parent().parent().find(".bookTags span[title='" + $(this).attr('title') + "']").length;
        if (checked_count * this_tag_count == 0) {
            $(this).find("input[type='checkbox']").removeAttr("checked");
            $(this).find("input[type='checkbox']").removeAttr("indeterminate");
            $(this).find("input[type='checkbox']").attr("status", "false");
        } else {
            if (checked_count > this_tag_count) {
                $(this).find("input[type='checkbox']").attr("indeterminate", true);
                $(this).find("input[type='checkbox']").removeAttr("checked");
                $(this).find("input[type='checkbox']").attr("status", "indeterminate");
            } else {
                $(this).find("input[type='checkbox']").removeAttr("indeterminate");
                $(this).find("input[type='checkbox']").attr("checked", "checked");
                $(this).find("input[type='checkbox']").attr("status", "true")
            }
        }
    });
}
var errTimes = 0;
var retrieving = false;
function retrieve_id_fun(eid, upass) {
    eid = eid.replace(/\'/g, "").replace(/\ /g, "");
    $("#retrieve_btn").attr('disabled', 'disabled');
    if (upass.length > 0) {
        $("#chkpassword").attr("checked", "checked");
        $("#p_password").show();
    }
    if (errTimes == 3) {
        $("#lblretrieve").css("color", "red");
        $("#lblretrieve").html("You have tried 3 times.");
        $("#retrieve_id").attr('disabled', 'disabled');
        $("#retrieve_btn").attr('disabled', 'disabled');
        popalert(_ts("accountislimitedtryagain2hours"));
        return;
    }
    if (eid.length > 0 && !retrieving && errTimes < 4) {
        retrieving = true;
        $("#lblretrieve").html(_ts("processing") + "...");
        $.ajax({
            type: "post",
            contentType: "application/json",
            url: "keys/retrieve_cloud_id.asmx/Retrieve",
            data: "{eID:'" + eid + "',userpassword:'" + upass + "'}",
            dataType: "json",
            success: function(result) {
                $.each(result.d, function(index, data) {
                    if (data.ID == 0) {
                        errTimes++;
                        $("#lblretrieve").html(data.Name);
                        $("#lblretrieve").css("color", "red");
                        $("#pfailednote").show();
                    } else {
                        $("#lblretrieve").css("color", "green");
                        $("#lblretrieve").html("Found,reloading...");
                        $.cookie("identify", data.ID, {
                            expires: 360,
                            path: '/'
                        });
                        $.cookie("user_localid", data.Name, {
                            expires: 360,
                            path: '/'
                        });
                        $.cookie("identifyusername", data.UserName, {
                            expires: 360,
                            path: '/'
                        });
                        $.cookie("uemail", data.email, {
                            expires: 360,
                            path: '/'
                        });
                        $.cookie("kindle_email", data.kindle_email, {
                            expires: 360,
                            path: '/'
                        });
                        $.cookie("isVip", data.isVip, {
                            expires: 360,
                            path: '/'
                        });
                        setTimeout(function() {
                            top.location.reload();
                        }, 2000);
                    }
                });
                if (result.d.length == 0) {
                    errTimes++;
                    $("#lblretrieve").html(_ts("failed"));
                    $("#lblretrieve").css("color", "red");
                    $("#pfailednote").show();
                }
                retrieving = false;
                $("#retrieve_btn").attr('disabled', '');
            },
            error: function() {
                $("#lblretrieve").html(_ts("systemerror"));
                $("#lblretrieve").css("color", "red");
                retrieving = false;
                $("#retrieve_btn").attr('disabled', '');
            }
        });
    } else {
        popalert("Input ID\/Name\/Email");
        retrieving = false;
        $("#retrieve_btn").attr('disabled', '');
    }
}
function iframeload(obj) {
    $('#TB_load').remove();
    if ($(obj).contents().find("div").length < 3) {} else {
        $("#tdframe").animate({
            'width': "320px"
        }, 120).show();
        $("#closeFrame").show();
    }
}
function closeFrame() {
    $("#closeFrame").hide();
    $("#tdframe").animate({
        'width': "1px"
    }, 120).show();
}
var showMessagesWindow = false;
function CheckUnReadCount() {
    if ($.cookie("messagescount") != "undefined") {
        if ($.cookie("messagescount") > 0) {
            $(".mmessage").show();
            $(".mmessages").show();
            $(".mmessages").css("display", "inline-table");
            $(".mmessages").html($.cookie("messagescount"));
            $(".mmessage").html($.cookie("messagescount"));
            if (!showMessagesWindow) {
                showMessagesWindow = true;
                setTimeout(function() {
                    tb_show(_ts('message'), '/app_books/messageslist.aspx?div=1&KeepThis=true&TB_iframe=true&height=480&width=330', false);
                }, 2000);
            }
        } else {
            $(".mmessage").hide();
            $(".mmessages").hide();
            $(".mmessages").html(0);
            $(".mmessage").html(0);
        }
    }
    return;
    $.ajax({
        type: "post",
        contentType: "application/json",
        url: "app_books/message_note_account.asmx/getunreadcount",
        data: "{uid:" + uid + ",isVip:" + isVip + "}",
        dataType: "text",
        cache: false,
        success: function(result) {
            $.each(result.d, function(index, data) {
                $(".mmessage").show();
                $(".messages").show();
            });
        },
        error: function() {}
    });
}
function favorite_click(obj) {
    $(".loading").show();
    $(".loading").html(_ts("processing") + "...");
    $.ajax({
        type: "post",
        contentType: "application/json",
        url: "app_books/favorite.asmx/favorite",
        data: "{uid:'" + uid + "',bid:'" + $(obj).attr("target") + "'}",
        dataType: "json",
        success: function(result) {
            $.each(result.d, function(index, data) {
                $(".loading").hide();
                if (data == '1') {
                    $(obj).parent(".divfavorite").toggleClass("fav");
                } else {}
            });
        },
        error: function() {
            popalert(_ts('systemerror'));
        }
    });
}
function feedback_click(obj, opt) {
    $(".loading").show();
    $(".loading").html(_ts("processing") + "...");
    var strbid;
    strbid = $(obj).parent().parent().parent().find("a.child_extension").attr("target");
    $.ajax({
        type: "post",
        contentType: "application/json",
        url: "app_books/feedback.asmx/feedback",
        data: "{uid:'" + uid + "',bid:'" + strbid + "',opt:'" + opt + "'}",
        dataType: "json",
        success: function(result) {
            $.each(result.d, function(index, data) {
                $(".loading").hide();
                if (data == '1') {
                    popalert(_ts('thanksforfeedingback'));
                    top.location.reload();
                } else {}
            });
        },
        error: function() {
            popalert(_ts('systemerror'));
        }
    });
}
function addTag(str) {
    $(".loading").show();
    $(".loading").html(_ts("processing") + "...");
    str.replace("'", "").replace('"', '').replace('<', '').replace('>', '');
    if (str.length > 0) {
        $.ajax({
            type: "post",
            contentType: "application/json",
            url: "app_books/addtag.asmx/addtag",
            data: "{uid:'" + uid + "',tagname:'" + str + "'}",
            dataType: "json",
            success: function(result) {
                $.each(result.d, function(index, data) {
                    if (data == '1') {
                        popalert(_ts('succeed'));
                        if (location.href.toString().indexOf("bookid=") > 0) {
                            top.location.href = "?";
                        } else {
                            top.location.reload();
                        }
                    } else {
                        popalert(data);
                    }
                });
            },
            error: function() {
                popalert(_ts('systemerror'));
            }
        });
    } else {
        popalert(_ts('inputtag'));
    }
}
function deletemybooks() {
    $(".loading").show();
    $(".loading").html(_ts("processing") + "...");
    var bids = '0';
    $(".book_child input[type='checkbox']:checked").parent().parent().find(".bid").each(function() {
        bids += ',' + $(this).text().replace("'", "");
    });
    $.ajax({
        type: "post",
        contentType: "application/json",
        url: "app_books/deletemybooks.asmx/deletemybooks",
        data: "{uid:" + uid + ",bids:'" + bids + "'}",
        dataType: "json",
        success: function(result) {
            $.each(result.d, function(index, data) {
                if (data == '1') {
                    popalert(_ts('succeed'));
                    if (location.href.toString().indexOf("bookid=") > 0) {
                        top.location.href = "?";
                    } else {
                        top.location.reload();
                    }
                } else {
                    popalert(data);
                }
            });
        },
        error: function() {
            popalert(_ts('systemerror'));
        }
    });
}
function compressmybooks() {
    if (isVip == "1") {
        $(".loading").show();
        $(".loading").html(_ts("processing") + "...");
        var bids = '0';
        $(".book_child input[type='checkbox']:checked").parent().parent().find(".bid").each(function() {
            bids += ',' + $(this).text().replace("'", "");
        });
        $.ajax({
            type: "post",
            contentType: "application/json",
            url: "app_books/compressFiles.asmx/compressFiles",
            data: "{uid:" + uid + ",bids:'" + bids + "'}",
            dataType: "json",
            success: function(result) {
                $.each(result.d, function(index, data) {
                    if (data.indexOf("getFile.ashx") > 0) {
                        popalert(_ts('succeed'));
                        top.location.href = '\/\/files.epubee.com' + data;
                    } else {
                        popalert(data);
                    }
                });
            },
            error: function() {
                popalert(_ts('systemerror'));
            }
        });
    } else {
        popalert(_ts('justforvip'));
    }
}
function setTags(obj, bool) {
    $(".loading").show();
    $(".loading").html(_ts("processing") + "...");
    var bids = '0';
    $(".book_child input[type='checkbox']:checked").parent().parent().find(".bid").each(function() {
        bids += ',' + $(this).text().replace("'", "");
    });
    if (bool) {} else {
        bool = $(obj).parent().find("input[type='checkbox']").attr("checked");
    }
    $.ajax({
        type: "post",
        contentType: "application/json",
        url: "app_books/setmybooktags.asmx/setmybooktags",
        data: "{uid:" + uid + ",bids:'" + bids + "',tagname:'" + $(obj).parent().find("input[type='checkbox']").attr("title").toString() + "',checked:'" + bool.toString() + "'}",
        dataType: "json",
        success: function(result) {
            $.each(result.d, function(index, data) {
                if (data == '1') {
                    popalert(_ts('succeed'));
                    if (location.href.toString().indexOf("bookid=") > 0) {
                        top.location.href = "?";
                    } else {
                        top.location.reload();
                    }
                } else {
                    popalert(data);
                }
            });
        },
        error: function() {
            popalert(_ts('systemerror'));
        }
    });
}
function deleteTags() {
    $(".loading").show();
    $(".loading").html(_ts("processing") + "...");
    var tagNames = '0';
    var checkedCount = 0;
    $("div.addtools .moretags ul li.dp_tag input[type='checkbox']:checked").each(function() {
        tagNames += ',' + $(this).attr("title");
        checkedCount += 1;
    });
    if (checkedCount > 0) {
        $.ajax({
            type: "post",
            contentType: "application/json",
            url: "app_books/deletemytags.asmx/deletemytags",
            data: "{uid:" + uid + ",tagnames:'" + tagNames + "'}",
            dataType: "json",
            success: function(result) {
                $.each(result.d, function(index, data) {
                    if (data == '1') {
                        popalert(_ts('succeed'));
                        if (location.href.toString().indexOf("bookid=") > 0) {
                            top.location.href = "?";
                        } else {
                            top.location.reload();
                        }
                    } else {
                        popalert(data);
                    }
                });
            },
            error: function() {
                popalert(_ts('systemerror'));
            }
        });
    } else {
        popalert(_ts('noitemselected'));
    }
}
function findbyemail(estr, obj) {
    estr = estr.replace(/\'/g, "").replace(/\ /g, "");
    if (estr.length > 6) {
        $(obj).html(_ts("processing") + "...");
        $.ajax({
            type: "post",
            contentType: "application/json",
            url: "app_books/findpasswordbyemail.asmx/sendEmail",
            data: "{email:'" + estr + "'}",
            dataType: "json",
            success: function(result) {
                $.each(result.d, function(index, data) {
                    if (data == 'nopassword') {
                        $(obj).html(_ts("accountdonotsetpassword"));
                    } else {
                        $(obj).html(data);
                    }
                });
            },
            error: function() {
                $(obj).html(_ts("systemerror"));
                $(obj).css("color", "red");
            }
        });
    } else {
        popalert(_ts('inputemail'));
    }
}
function retrieve_email(trade_no, u_id, obj) {
    if (trade_no.length > 8 && u_id.length > 2) {
        $(obj).html(_ts("processing") + "...");
        $.ajax({
            type: "post",
            contentType: "application/json",
            url: "app_books/retrieve_account_email.asmx/retrieve_email",
            data: "{trade_no:'" + trade_no + "',u_id:'" + u_id + "'}",
            dataType: "json",
            success: function(result) {
                $.each(result.d, function(index, data) {
                    $(obj).html(data);
                });
            },
            error: function() {
                $(obj).html(_ts("systemerror"));
                $(obj).css("color", "red");
            }
        });
    } else {
        popalert(_ts('pleaseinputthecorrectpaymentidandaccountid'));
    }
}
function popalert(str) {
    $(".loading").html(str);
    $(".loading").show();
    setTimeout(function() {
        $(".loading").hide();
    }, 2000);
}
click_key =  function(initurl) {
    popalert(_ts("processing"));
    $.ajax({
        type: "post",
        contentType: "application/json",
        url: "app_books/click_key.asmx/getkey",
        data: "{isVip:" + 1 + ",uid:" + uid + ",strbid:'" + initurl + "'}",
        dataType: "json",
        success: function(result) {
            $.each(result.d, function(index, data) {
                if (data == 'limited') {
                    popalert(_ts("downloadtimelimited"));
                    setTimeout(function() {
                        tb_show(_ts("message") + 'ID:' + uid, '/app_books/limited.aspx?utm_medium=cnepubee&utm_source=cnepubee&utm_campaign=downloadlimited&utm_content=downloadlimited&div=1&limited=time&KeepThis=true&TB_iframe=true&height=500&width=330', false);
                    }, 200);
                } else if (data == 'timeout') {
                    popalert(_ts('timeoutpleaserefreshtheebookmanagerpage'));
                } else {
                    if (isWeiXin()) {
                        popalert(_ts('clicktherighttopandopenitonbrowser'));
                    } else {
                        var u = window.navigator.userAgent;
                        if ((u.indexOf('Safari') + u.indexOf('Chrome') + u.indexOf('CriOS') + u.indexOf('MSIE') + u.indexOf('Trident') + u.indexOf('Edge') + u.indexOf('Firefox') + u.indexOf('Opera') + u.indexOf('OPR')) > 0) {
                            popalert(_ts('startdownloadconfirmin3senconds'));
                        } else {
                            popalert(_ts('pleasechangebrowsertodownload'));
                        }
                        $.cookie("download_for_second", data, {
                            expires: 1,
                            path: '/'
                        });
                        var download_url = "http:\/\/files.epubee.com/getFile.ashx?bid=" + initurl + '&uid=' + uid + '&t_key=' + data;
                        top.location.href = download_url;
                    }
                }
            });
        },
        error: function() {
            popalert(_ts('systemerror'));
            return false;
        }
    });
    return false;
}
function isWeiXin() {
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        return true;
    } else {
        return false;
    }
}
